<%@ include file="/taglibs.jsp"%>

<title>Winter War Administration - Events</title>

<button onclick="location.href='event.do?method=edit&amp;conID=${conID }'">Add Event</button>

<c:choose>
	<c:when test="${status == 1 || status == 2}">
		<display:table name="events" id="event" pagesize="10" requestURI="event.do?method=list&amp;conID=${conID }">
			<display:column property="eventID" paramId="eventID" paramProperty="eventID" href="event.do?method=edit&conID=${conID }"  sortable="true"/>
			<display:column property="eventName" title="Event Name"/>
			<display:column  title="GM Name" sortable="true" >
				 ${event.user.lastName }, ${event.user.firstName }
			</display:column>
			<display:column property="status" title="Status">
				<c:choose>
					<c:when test="${event.status == 1 }">Submitted</c:when>
					<c:when test="${event.status == 2 }">In Review</c:when>
					<c:when test="${event.status == 3 }">Accepted</c:when>
					<c:when test="${event.status == 4 }">Rejected</c:when>
				</c:choose>
			</display:column>
			<display:column property="totalSeats" title="Seats"/>
			<display:column property="slotName" title="Requested Slot"/>
			<display:column property="insertDate" sortable="true" title="Submitted On"/>
		</display:table>
	</c:when>
<c:otherwise>
<table class="list">
	<thead>
		<tr>
			<th><bean:message key="event.eventName"/></th>
			<th><bean:message key="event.runner"/></th>
			<th><bean:message key="event.status"/></th>
			<th><bean:message key="event.totalSeats"/></th>
			<th><bean:message key="event.slotName"/></th>
			<th><bean:message key="event.tableName"/></th>
		</tr>
	</thead>
	<tbody>
		<c:set scope="page" var="oldSlot" value="0"/>
		<c:forEach var="event" items="${events}" varStatus="status">
			<c:set scope="page" var="curSlot" value="${event.slotID }"/>
			<c:choose>
				<c:when test="${status.count % 2 == 0}"><tr class="even"></c:when>
				<c:otherwise><tr class="odd"></c:otherwise>
			</c:choose>
			<c:choose>
				<c:when test="${curSlot != oldSlot}">
					<c:set scope="page" var="oldSlot" value="${curSlot }"/>
					<td colspan="6"><hr></td>
					</tr><tr>
				</c:when>
			</c:choose>
				<td><a href="event.do?method=edit&amp;eventID=${event.eventID}&amp;conID=${conID }">${event.eventName}</a></td>
				<td>${event.username }</td>
				<td>
					<c:choose>
						<c:when test="${event.status == 1 }">Submitted</c:when>
						<c:when test="${event.status == 2 }">In Review</c:when>
						<c:when test="${event.status == 3 }">Accepted</c:when>
						<c:when test="${event.status == 4 }">Rejected</c:when>
					</c:choose>
				</td>
				<c:choose>
				<c:when test="${event.status == 1 }"><td>${event.totalSeats}</td></c:when>
				<c:when test="${event.status == 2 }"><td>${event.totalSeats}</td></c:when>
				<c:when test="${event.status == 3 }"><td>${event.reservedSeats} / ${event.totalSeats}</td></c:when>
				<c:when test="${event.status == 4 }"><td>${event.totalSeats}</td></c:when>
				</c:choose>
				<td>${event.slotName}</td>
				<td>${event.tableName}</td>
			</tr>
		</c:forEach>
	</tbody>
</table>
</c:otherwise>
</c:choose>